package com.wudimeng.syll.controller.api;


import com.wudimeng.syll.common.ApiResponse;
import com.wudimeng.syll.constants.Constant;
import com.wudimeng.syll.entity.CChuKuXinXi;
import com.wudimeng.syll.service.ICChuKuXinXiService;
import com.wudimeng.syll.service.IChanPinXinXiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author laohei
 * @Date 2020/6/8 9:50
 * @Version 1.0
 */
@RestController
@Slf4j
@RequestMapping("syll")
public class ChanPinXinXiController {

    @Autowired
    private IChanPinXinXiService service;

    @GetMapping("/ChanPinXinXi")
    public ApiResponse getChanPinXinXi(HttpServletRequest  request){
        try {
            return this.service.selectChanPinXinXi(null);
        } catch (Exception e) {
            log.error("ChanPinXinXiController.getChanPinXinXi.请稍后再试:" + e.getMessage());
            return ApiResponse.error(Constant.COMMON_PARAMETER_DEGRADE);
        }
    }

    @GetMapping("/LengKuXinXi")
    public ApiResponse getLengKuXinXi(HttpServletRequest  request){
        try {
            String YongHuID = request.getParameter("YongHuID");
            String WeiTuoID = request.getParameter("WeiTuoID");
            Map<String,String> paramMap = new HashMap<>();
            paramMap.put("YongHuID",YongHuID);
            paramMap.put("WeiTuoID",WeiTuoID);
            return this.service.selectLengKuXinXi(paramMap);
        } catch (Exception e) {
            log.error("ChanPinXinXiController.getLengKuXinXi.请稍后再试:" + e.getMessage());
            return ApiResponse.error(Constant.COMMON_PARAMETER_DEGRADE);
        }
    }

}
